# Contributor: Duncan Bellamy <dunk@denkimushi.com>
# Maintainer: Duncan Bellamy <dunk@denkimushi.com>
pkgname=dovecot-ceph-plugin
pkgver=0.0.23
pkgrel=3
_gtestver=1.11.0
pkgdesc="Dovecot plugin for storing mails in a Ceph cluster"
url="https://github.com/ceph-dovecot/dovecot-ceph-plugin"
arch="all !riscv64" # blocked by ceph
license="LGPL-2.1-or-later"
depends="dovecot"
makedepends="
	automake
	autoconf
	ceph-dev
	dovecot-dev
	jansson-dev
	libexecinfo-dev
	libtool
	linux-headers
	"
subpackages="librmb:_librmb librmb-dev:_librmb_dev librmb-doc:_librmb_doc librmb-utils:_librmb_utils"
source="$pkgname-$pkgver.tar.gz::https://github.com/ceph-dovecot/dovecot-ceph-plugin/archive/refs/tags/$pkgver.tar.gz
	https://github.com/google/googletest/archive/refs/tags/release-$_gtestver.tar.gz
	1-fixes.patch
	2-fixes.patch
	3-fixes.patch
	6-32bit.patch
	7-sentinel.patch
	"

prepare() {
	default_prepare
	ln -s "$srcdir"/googletest-release-"$_gtestver"/googletest \
		src/tests/googletest/googletest
	ln -s "$srcdir"/googletest-release-"$_gtestver"/googlemock \
		src/tests/googletest/googlemock
	autoreconf -vif
}

build() {
	export CFLAGS="$CFLAGS -fPIC"
	export CXXFLAGS="$CXXFLAGS -fPIC"
	export LIBS="$LIBS -lexecinfo"

	./configure --prefix=/usr --with-dovecot=/usr/lib/dovecot
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install
}

_librmb() {
	pkgdesc="RADOS mailbox library"
	amove usr/lib/librmb.so.*
}

_librmb_dev() {
	pkgdesc="RADOS mailbox headers"
	default_dev
}

_librmb_doc() {
	default_doc
}

_librmb_utils() {
	pkgdesc="RADOS mailbox tools"
	amove usr/bin/rmb
}

sha512sums="
6476d98b59fd8adfb49dee478a234ec2327c76712074e8842db24f8a9982c53f68d3b917a096b707efae01862e096e378c435006a316b7d43a8ffa0263075a54  dovecot-ceph-plugin-0.0.23.tar.gz
6fcc7827e4c4d95e3ae643dd65e6c4fc0e3d04e1778b84f6e06e390410fe3d18026c131d828d949d2f20dde6327d30ecee24dcd3ef919e21c91e010d149f3a28  release-1.11.0.tar.gz
d6b25ee5a9b990e3f196292b3d160210c39d1cbec1abc71a938733aed0508c991dcb14f78b84c5cc4dece35cdc1af35517dec695eb019d1c62bb55cc6acd2e79  1-fixes.patch
0c2267140dfd532dd191e8c0cc0cd54a47c57222879664c24c724d6846cff7d435aacfae077439c882156c982e004917f428415e7497fe40d6f3f1f680b5da6e  2-fixes.patch
585ef94845d03ff49fd8a02db2ff8075c4a0eba545d98b22558b23f587bb475f4682d5b6cfd7f33f8617ffbec00f190a26521433c4f1ba1d3a2e78e9940ddc37  3-fixes.patch
a71e6b2236c29f3b65ed043ba5548c3494bedc40d5db2eabad54158eccc0b7c4dda328d878064031fb0b8088fb3a38c8d41ae4049a8f0fd57f89b16cc92267f5  6-32bit.patch
df836f24d8133228537b003dbdc4f917892f50dbe3dc7c374d6e242890e879a31ed1f8259ceb88df43dcea281b1be612171714417407b57db38827f834f1fcdd  7-sentinel.patch
"
